home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
INITIAL2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-14
|
15KB
|
490 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 9-14-88 6:15 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit Initial2;
Interface
Uses
TpCrt, Dos, Globals, TPSTRING, TPDOS,
TAccess, Core1, Core2, Misc;
procedure setup;
procedure wait_for_user;
procedure get_nmh;
{==========================================================================}
Implementation
procedure setup;
var
i, x : Integer;
first, OK : Boolean;
test_file : file;
begin
valid_pw := False;
first := False;
fini := False;
connected := False;
local_online := False;
local_copy := True;
printer_copy := False;
remote_online := False;
remote_copy := False;
macro_file_exists := False;
AreaReq := '';
SectReq := '';
mode := message_mode; { Start system in message mode }
nonstop := False; { no message scrolling}
st_switch := True; { Default file size display - in 'k' }
new_dir := False; { Reset directory flag }
up_down_display := True; { Show up/downloads for files mode }
extra_time := 0; { None until upload complete }
op_chat := False; { chat not initiated }
in_chat := False;
last_time_left := 6;
user_rec.nulls := 2; { 2 nulls until recognition }
user_rec.shift_lock := False; { Upper case only to start }
user_rec.noisy := False; { Prompt bell initially off }
user_rec.columns := def_chars;
user_rec.lines := def_lines;
timeout := 60; { Allow one minute for input }
Assign(test_file, user_data+ext);
{$I-}
Reset(test_file); {$I+}
if IoResult = 0 then
begin
OK := (FileSize(test_file) > 0);
Close(test_file)
end
else
OK := False;
if OK then
begin
Assign(test_file, user_indx+ext);
{$I-}
Reset(test_file); {$I+}
if IoResult = 0 then
begin
OK := (FileSize(test_file) > 0);
Close(test_file)
end
else
OK := False;
end;
if OK then
begin
OpenFile(DatF, user_data+ext, SizeOf(user_rec));
OpenIndex(IdxF, user_indx+ext, len_ln+len_fn, 0)
end
else
begin
WriteLn(BEL, BEL, BEL, 'IMPORTANT');
WriteLn('If your CONFIG.SYS file does not contain a FILES=20 statement');
WriteLn('an I/O error will occur during this initialization !');
WriteLn;
Delay(5000);
Write(BEL, 'User files not found. Creating ', user_data, ext);
MakeFile(DatF, user_data+ext, SizeOf(user_rec));
Write(', ', user_indx, ext);
MakeIndex(IdxF, user_indx+ext, len_ln+len_fn, 0);
WriteLn;
first := True;
end;
if (not ExistFile(area_indx+ext)) then
begin
WriteLn(BEL, 'Newin index not found. Creating ', area_indx, ext);
MakeIndex(NewinArea, area_indx+ext, 12, Duplicates);
end
else
OpenIndex(NewinArea, area_indx+ext, 12, Duplicates);
if (not ExistFile(name_indx+ext)) then
begin
WriteLn(BEL, 'Newin index not found. Creating ', name_indx, ext);
MakeIndex(NewinName, name_indx+ext, 12, Duplicates);
end
else
OpenIndex(NewinName, name_indx+ext, 12, Duplicates);
{$I-}
Reset(logr_file) {$I+} ;
OK := (IoResult = 0);
if (not OK) or (OK and (FileSize(logr_file) = 0)) then
begin
Write(BEL, 'Log file not found. Creating ', logr_name, ext);
Rewrite(logr_file);
logr_rec.user := 0;
Write(logr_file, logr_rec);
FlushAny(logr_file);
WriteLn;
first := True;
end;
{$I-}
Reset(summ_file) {$I+} ;
OK := (IoResult = 0);
if OK then
begin
{$I-}
Reset(mesg_file) {$I+} ;
OK := (IoResult = 0)
end;
if (not OK) or (OK and (FileSize(summ_file) = 0)) then
begin
Write(BEL, 'Message files not found. Creating ', summ_name, ext);
Rewrite(summ_file);
summ_rec.num := 0;
Write(summ_file, summ_rec);
Write(', ', mesg_name, ext);
Rewrite(mesg_file);
WriteLn;
first := True;
end;
Assign(stat_file, stat_name+ext);
{$I-}
Reset(stat_file) {$I+} ;
if (IoResult = 0) and (FileSize(stat_file) > 0) then
Read(stat_file, stat_rec)
else
begin
Write(BEL, 'Statistics file not found. Creating ', stat_name, ext);
Rewrite(stat_file);
GetTAD(stat_rec.date);
for i := 0 to 23 do
stat_rec.busy_per_hour[i] := 0;
for i := 0 to 6 do
stat_rec.busy_per_day[i] := 0;
WriteLn;
first := True;
end;
Close(stat_file);
{$I-}
Reset(nwin_file) {$I+} ;
if IoResult <> 0 then
begin
Write(BEL, 'Newin file not found. Creating ', nwin_name, ext);
Rewrite(nwin_file);
with nwin_rec do
begin
name := 'ENTRY.1ST';
descr := ('A dummy entry');
GetTAD(date);
user := 0;
sectn := '*NEWIN';
status := public;
dnloads := 0;
for x := 0 to 5 do
last_dnload[x] := 0;
end;
Write(nwin_file, nwin_rec);
WriteLn;
first := True;
end;
if (not ExistOnPath('COMMAND.COM', CommandPath)) then
begin
Write(BEL, 'Couldn''t find COMMAND.COM in path. Aborting.. ');
Halt
end
else
CommandPath := FullPathName(CommandPath);
if (not ExistOnPath('DSZ.COM', DSZPath)) and (not ExistOnPath('DSZ.EXE', DSZPath)) then
begin
Write(BEL, 'Couldn''t find DSZ in path. Aborting.. ');
Halt
end
else
DSZPath := FullPathName(DSZPath);
if cold then
begin
if (not cmd_tail) then log(0, '');
cold := False;
end;
if first then
Delay(5000);
end;
procedure wait_for_user;
var
ch : Char;
bt : Byte;
count_limit,
count,
counter, i, x,
delay_count,
resend : Integer;
t : tad_array;
timeout : Boolean;
Rcv_Space,
Hom_space : Longint;
begin
NetMsgEntr := 0;
EchoMsgEntr := 0;
if (not cmd_tail) or (cmd_tail and (strint(ParamStr(1)) = 99))
or (cmd_tail and (strint(ParamStr(1)) = 98)) then
begin
ClrScr;
count_limit := 12000;
if delay_down then
begin
putstat('Waiting for delayed shutdown acknowledgement...', ' ');
mdbusy;
end
else
begin
putstat(Center(version+' as of '+ver_date+
' Copyright (c) 1987,88 by', 79),
Center('Jon Schneider & Rick Petersen, El Paso, TX.', 79)
);
if (not cmd_tail) then mdinit;
end;
GetTAD(t);
Rcv_Space := (diskfree(Ord(Upcase(RcvDrv[1]))-64) div 1024);
Hom_space := (diskfree(Ord(Upcase(HomDrv[1]))-64) div 1024);
if macro_in_progress then
begin
macro_in_progress := False;
if macro_file_exists then
begin
Close(macro_file);
macro_file_exists := False;
end;
GetTAD(t);
macro_done := t[3];
local_online := False;
end;
count := 0;
counter := 0;
delay_count := 0;
resend := 0;
repeat
if ((auto_macro) and (macro_done <> t[3]) and (t[2] >= auto_macro_start)
and (not macro_in_progress)) or
(cmd_tail and (strint(ParamStr(1)) = 98)) then
begin
Assign(macro_file, 'MACRO.LST');
{$I-}
Reset(macro_file); {$I+}
if IoResult = 0 then
begin
macro_file_exists := True;
WriteLn('Starting auto macro execution.');
macro_in_progress := True;
end;
if (not macro_file_exists) and (Length(macro) > 0) then
begin
WriteLn('Starting auto macro execution.');
macro_in_progress := True;
st := macro;
repeat
i := Pos('^M', st);
if i > 0 then
begin
Delete(st, i, 2);
Insert(Chr(13), st, i);
end;
until i = 0;
Cmd_Queue := st;
mult_cmds := True;
end;
end;
if (counter > 30000) or (counter = 0) then
begin
if delay_down then
begin
ClrScr;
WriteLn;
GoToXY(5, 20);
WriteLn('COUNT DOWN TO SYSTEM RE-ACTIVATION... ', 75-delay_count);
WriteLn;
end;
GoToXY(10, 15);
if Rcv_Space < maxfree_uplds then
WriteLn('UPLOADS OFF DUE TO DISK SPACE LIMITS !');
if Hom_space < maxfree_logs then
WriteLn('NEW LOGINS OFF DUE TO DISK SPACE LIMITS !');
if Hom_space < maxfree_mslimit then
WriteLn('MESSAGES LIMITED DUE TO DISK SPACE LIMITS !');
if (Hom_space < maxfree_abs) or (Rcv_Space < maxfree_abs) then
begin
WriteLn;
WriteLn('EXTREME DISK SPACE PROBLEMS !!!!!!!!!');
end;
counter := 1;
end;
Inc(count);
Inc(counter);
if counter = 10000 then
ClrScr;
if count > count_limit then
begin
GetTAD(t);
putstat('', '');
GoToXY(Succ(Random(79)), Succ(Random(23)));
count := 0;
Inc(resend);
if resend > 200 then
begin
resend := 0;
mdinit
end;
if delay_down then
Inc(delay_count);
end;
if delay_down then
begin
Write(BEL);
if delay_count >= 75 then
begin
delay_down := False;
delay_count := 0;
mdhangup;
end;
end;
ch := GetChar;
if (ch = LF) or (ch = CR) then
begin
ClrScr;
WriteLn;
WriteLn(Center(' '+version+' as of '+ver_date, 79));
WriteLn(Center(' Copyright (c) 1987,88 by', 79));
WriteLn(Center(' Jon Schneider & Rick Petersen, El Paso, TX.', 79));
GotoXY(1, 20);
WriteLn(Center(' ^C to exit TPBoard, ^L for local use.', 79));
HiddenCursor;
MakeWindow;
i := 1;
if Ch_Carck then
x := 30
else
x := 32000;
repeat
bt := GetByte(1, timeout);
if bt > 0 then
i := x; {key pressed remotely}
Inc(i);
until KeyPressed or (i >= x);
NormalCursor;
ClrScr;
end;
if ch = ETX then
begin
ClrScr;
WriteLn;
Write('Busy modem [Y/n] ? >');
ch := ReadKey;
if Upcase(ch) = 'N' then
mdhangup
else
mdbusy;
ClrScr;
WriteLn;
WriteLn('TPBoard completing...');
log(1, '');
CloseFile(DatF);
CloseIndex(IdxF);
Close(sysm_file);
Close(summ_file);
Close(mesg_file);
Close(logr_file);
Close(stat_file);
Close(nwin_file);
fini := True
end
else if (ch = FF) or (macro_in_progress)
or (cmd_tail and (strint(ParamStr(1)) = 99))
{control L}
then
begin
putstat('Local use requested', ' ');
rate := 300;
mdbusy;
local_online := True
end
else if mdring then
begin
putstat('Ring detected', ' ');
mdans;
remote_online := Ch_Carck;
remote_copy := remote_online;
if remote_online then
putstat('Connect at '+intstr(rate, 3)+' bps', ' ');
end
until fini or local_online or remote_online;
delay_down := False
end
else
begin
ClrScr;
Rcv_Space := (diskfree(Ord(Upcase(RcvDrv[1]))-64) div 1024);
Hom_space := (diskfree(Ord(Upcase(HomDrv[1]))-64) div 1024);
rate := strint(ParamStr(1));
time_to_event := strint(ParamStr(2));
if time_to_event = 0 then
get_nmh;
Ch_Init;
Ch_Set(rate);
remote_online := Ch_Carck;
remote_copy := remote_online;
delay_down := False
end;
end;
procedure get_nmh;
var
t : tad_array;
current, nmh : Integer;
begin
GetTAD(t);
current := (60*t[2])+t[1];
nmh := 60*auto_macro_start;
if nmh < current then
nmh := nmh+1440;
time_to_event := nmh-current
end;
end. { of INITIAL2.PAS }